#ifndef MOCHA_DETAIL_GRAPHICS_PLUGIN_H_INCLUDED
#define MOCHA_DETAIL_GRAPHICS_PLUGIN_H_INCLUDED

/**
 * @file
 */

#include <stdint.h>
#include "mocha/color.h"
#include "mocha/memory.h"
#include "mocha/plugin.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Provides basic information about the capabilities of both the underlying graphics implementations and the current hardware.
 * Depending on the current platform and implementation, not all information may be accurate.
 */
typedef struct MOCHA_PACKED mocha_graphics_caps {
	/**
	 * Device flags.
	 */
	union MOCHA_PACKED {
		uint32_t dev_flags;
		struct MOCHA_PACKED {
			/// Set if the device is hardware accelerated.
			int accel : 1;
			/// Set if the device supports vertical syncing. Note that even though this flag may be set, vertical syncing may not be available in all display modes.
			int vsync : 1;
		} bits;
	} dev_flags;
	/// Maximum display width (horizontal resolution). Zero if no limit can be detected.
	uint32_t max_display_width;
	/// Maximum display height (vertical resolution). Zero if no limit can be detected.
	uint32_t max_display_height;
	/// Maximum display color depth.
	uint32_t max_display_depth;
	/**
	 * Image flags.
	 */
	union MOCHA_PACKED {
		uint32_t image_flags;
		struct MOCHA_PACKED {
			/// Set if software blitting is supported.
			int blit : 1;
		} bits;
	} image_flags;
	/// Maximum supported image width. Zero if no limit can be detected.
	uint32_t max_image_width;
	/// Maximum supported image height. Zero if no limit can be detected.
	uint32_t max_image_height;
	/// Mask of supported image file formats.
	uint64_t image_file_formats;
	/**
	 * Texture flags
	 */
	union MOCHA_PACKED {
		uint32_t tex_flags;
		struct MOCHA_PACKED {
			/// Set if non-power-of-two textures are supported.
			int non_pow_2 : 1;
		} bits;
	} tex_flags;
	/// Maximum texture width. Zero if no limit can be detected.
	uint32_t max_tex_width;
	/// Maximum texture height. Zero if no limit can be detected.
	uint32_t max_tex_height;
	/// Mask of supported texture filters.
	uint32_t tex_filters;
} mocha_graphics_caps;
/**
 * 
 */
typedef struct mocha_c_graphics_plugin {
	/**
	 * @return Plugin type name (as a vanilla string).
	 */
	const mocha_plugin_char_t *(*type_name)(const struct mocha_c_graphics_plugin *self); // const
	/**
	 * 
	 */
	int32_t (*capabilities)(const struct mocha_c_graphics_plugin *self, mocha_graphics_caps *caps); // const
	/**
	 * 
	 */
	int32_t (*open_display_mode)(struct mocha_c_graphics_plugin *self, uint32_t width, uint32_t height, int8_t full);
	/**
	 * 
	 */
	int32_t (*swap_buffers)(struct mocha_c_graphics_plugin *self);
	/**
	 * 
	 */
	int32_t (*clear_back_buffer)(struct mocha_c_graphics_plugin *self, mocha_rgba_t cc);
	struct mocha_c_graphics_plugin *self;
} mocha_c_graphics_plugin;

#ifdef __cplusplus
} // extern "C"
#endif

#endif

